package tool;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.*;

/**
 * 按行读某文件
 * 
 * @author chz
 * 
 */
public class ReadTool {

	private static final String[] str = null;

	public ReadTool() {

	}

	public static ArrayList<String> writeToDat(String path) {
		ArrayList	<String> list=new ArrayList<String>();
		File file = new File(path);
		
		
		try {
			BufferedReader bw = new BufferedReader(new FileReader(file));
			String line = null;
			// 因为不知道有几行数据，所以先存入list集合中
			while ((line = bw.readLine()) != null) {
				list.add(line);
			}
			bw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		// 确定数组长度
		
		
		return list;
	}

	public static void main(String[] args) {

		String path = "/Users/chz/Desktop/test.txt";
		List<String> nums = writeToDat(path);
		for (int i = 0; i < nums.size(); i++) {
			System.out.println(nums.get(i));
		}
	}

}
